package ar.edu.itba.pod.Legajo47342;

import java.rmi.RemoteException;

import ar.edu.itba.pod.simul.communication.ThreePhaseCommit;

public class TPCWaitThread extends Thread implements Runnable{

	private long timeout;
	private ThreePhaseCommit commit;
	
	public TPCWaitThread(long timeout, ThreePhaseCommit commit) {
		super();
		this.timeout = timeout;
		this.commit = commit;
	}

	@Override
	public void run() {
		try {
			Thread.sleep(timeout);
		} catch (InterruptedException e) {
			System.out.println("Wait interrupted, continue to next state");
			return;
		}
		//aca se paso el timeout y tengo que abortar
		try {
			commit.onTimeout();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
}
